package com.gzhryc.shared_device.bxscn.core.protocol.v1.msg;

import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

public class FRResponse implements Serializable {

	private static final long serialVersionUID = 1L;

	public final static String CMD = "FR";

	private String cmd = CMD;
	private String messageId;
	private String deviceSn;
	private Integer slotNum;
	private Integer resultCode;
	private String crc;

	public FRResponse() {
	}

	public FRResponse(BaseMessage baseMessage) {
		String[] data = baseMessage.getData();
		this.deviceSn = baseMessage.getDeviceSn();
		this.messageId = baseMessage.getMessageId();
		if (data != null) {
			if (data.length >= 1) {
				if (StringUtils.isNotBlank(data[0])) {
					this.resultCode = Integer.valueOf(data[0]);
				}
			}
			if (this.resultCode != null) {
				if (this.resultCode > 0 && this.resultCode < 100) {
					this.slotNum = this.resultCode;
				}
			}
			if (data.length >= 2) {
				this.crc = data[1];
			}
		}
	}

	public String getCmd() {
		return cmd;
	}

	public void setCmd(String cmd) {
		this.cmd = cmd;
	}

	public String getMessageId() {
		return messageId;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}
	
	public String getDeviceSn() {
		return deviceSn;
	}

	public void setDeviceSn(String deviceSn) {
		this.deviceSn = deviceSn;
	}

	public Integer getSlotNum() {
		return slotNum;
	}

	public void setSlotNum(Integer slotNum) {
		this.slotNum = slotNum;
	}

	public String getCrc() {
		return crc;
	}

	public void setCrc(String crc) {
		this.crc = crc;
	}

	public Integer getResultCode() {
		return resultCode;
	}

	public void setResultCode(Integer resultCode) {
		this.resultCode = resultCode;
	}
}
